/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * Main.java
 *
 * Created on 24.09.2010, 11:23:18
 */
package ru.ibrae.excelparser1.gui;

import java.awt.Cursor;
import java.awt.Font;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JToolBar;
import javax.swing.LayoutStyle.ComponentPlacement;
import javax.swing.SwingConstants;
import ru.ibrae.cr.domain.Person;
import ru.ibrae.cr.orm.AbstractEntity;
import ru.ibrae.excelparser1.excelstorageentities.entities.OrganizationInfo;
import ru.ibrae.excelparser1.mainlogics.CheckResult;
import ru.ibrae.excelparser1.mainlogics.dbwork.DatabaseWorker;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.InputEvent;
import java.awt.event.KeyEvent;
import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;
import javax.swing.JCheckBoxMenuItem;
import javax.swing.JLabel;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JPopupMenu.Separator;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.KeyStroke;
import javax.swing.WindowConstants;
import java.awt.HeadlessException;
import ru.ibrae.excelparser1.mainlogics.fileworkers.FileNameParser;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JFileChooser;
import javax.swing.JOptionPane;
import javax.swing.SwingUtilities;
import javax.swing.SwingWorker;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
import javax.swing.filechooser.FileNameExtensionFilter;
import jxl.Cell;
import jxl.read.biff.BiffException;
import ru.ibrae.cr.client.DbType;
import ru.ibrae.cr.client.TestInitializer;
import ru.ibrae.excelparser1.excelstorageentities.entities.CertificateInfo;
import ru.ibrae.excelparser1.excelstorageentities.entities.ExcelField;
import ru.ibrae.excelparser1.excelstorageentities.entities.ExcelFile;
import ru.ibrae.excelparser1.excelstorageentities.entities.MessageLevel;
import ru.ibrae.excelparser1.excelstorageentities.entities.PersonInfo;
import ru.ibrae.excelparser1.mainlogics.config.Configuration;
import ru.ibrae.excelparser1.mainlogics.config.ConfigurationWorker;
import ru.ibrae.excelparser1.mainlogics.constructors.ExcelEntitiesConstructor;
import ru.ibrae.excelparser1.mainlogics.fileworkers.FileNameParser.FileNameVerificaionResult;
import ru.ibrae.excelparser1.mainlogics.fileworkers.FileToFixCreator;
import ru.ibrae.excelparser1.mainlogics.Logging.implimentation.ComplexLogger;
import ru.ibrae.excelparser1.mainlogics.datapush.PushEntity;

/**
 *
 * @author murr
 */
public class Main extends javax.swing.JFrame {

    private static HashMap<Integer, Class> fillMap() {
        HashMap<Integer, Class> celltypes = new HashMap<Integer, Class>(21);
        celltypes.put(0, Integer.class);
        celltypes.put(1, String.class);
        celltypes.put(2, Date.class);
        celltypes.put(3, String.class);
        celltypes.put(4, String.class);
        celltypes.put(5, String.class);
        celltypes.put(6, Date.class);
        celltypes.put(7, String.class);
        celltypes.put(8, String.class);
        celltypes.put(9, String.class);
        celltypes.put(10, String.class);
        celltypes.put(11, Date.class);
        celltypes.put(12, String.class);
        celltypes.put(13, String.class);
        celltypes.put(14, String.class);
        celltypes.put(15, Date.class);
        celltypes.put(16, String.class);
        celltypes.put(17, String.class);
        celltypes.put(18, String.class);
        celltypes.put(19, Date.class);
        celltypes.put(20, String.class);

        return celltypes;
    }
    private Long orgId = null;
    private FileNameVerificaionResult fileNameVerificaionResult;

    /** Creates new form Main */
    public Main() {
        try {
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        }
        catch (ClassNotFoundException ex) {
            Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
        }
        catch (InstantiationException ex) {
            Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
        }
        catch (IllegalAccessException ex) {
            Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
        }
        catch (UnsupportedLookAndFeelException ex) {
            Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
        }
        login();
        initComponents();
        setLocationRelativeTo(null);
    }

    private void login() throws HeadlessException {
        try {
            TestInitializer.start(DbType.LINTER);
        }
        catch (Throwable ex) {
            int i = JOptionPane.showConfirmDialog(null, "Ошибка подключения к базе данных.\nПопробовать еще раз?", "Ошибка подключения к базе данных", JOptionPane.YES_NO_OPTION, JOptionPane.ERROR_MESSAGE);
            if (i == JOptionPane.NO_OPTION) {
                System.exit(i);
            } else {
                TestInitializer.stop();
                login();
            }
        }
    }

    private boolean checkExcelField(ExcelField excelField, OrganizationInfo info) {
        try {
            pushEntity = new PushEntity();
            pushEntity.setOrganiztionId(orgId);
            int brSize = brokenRows.size();
            CheckResult<AbstractEntity> certificateCheck = DatabaseWorker.certificateCheck(excelField, orgId);
            pushEntity.setCertificate(excelField.getMchsLetter().getPerson().getCurrentCertificate());
            if (certificateCheck.getEntity() != null) {
                pushEntity.setCertificateId(certificateCheck.getEntity()[0].getId());
            }
            pushEntity = DatabaseWorker.push(pushEntity, excelField.getMchsLetter(), info);
            /* if (!pushEntity.isLoadedSuccessfully()) {
            return true;
            }*/
            brokenRows = checkPushEntity(pushEntity, excelField, CertificateInfo.class, brokenRows);
            if (brSize != brokenRows.size()) {
                brSize = brokenRows.size();
                return true;
            }
            if (certificateCheck.isLoaded() && certificateCheck.getEntity().length == 2) {
                pushEntity.setPerson(excelField.getMchsLetter().getPerson());
                pushEntity.setPersonId(certificateCheck.getEntity()[1].getId());
                pushEntity = DatabaseWorker.push(pushEntity, excelField.getMchsLetter(), info);
                brokenRows = checkPushEntity(pushEntity, excelField, PersonInfo.class, brokenRows);
                if (brSize != brokenRows.size()) {
                    brSize = brokenRows.size();
                    return true;
                }
            } else {
                CheckResult<Person> personCheck = DatabaseWorker.personCheck(excelField);
                pushEntity.setPerson(excelField.getMchsLetter().getPerson());
                if (personCheck.isLoaded()) {
                    pushEntity.setPersonId(personCheck.getEntity()[0].getId());
                }
                pushEntity = DatabaseWorker.push(pushEntity, excelField.getMchsLetter(), info);
                brokenRows = checkPushEntity(pushEntity, excelField, PersonInfo.class, brokenRows);
                if (brSize != brokenRows.size()) {
                    brSize = brokenRows.size();
                    return true;
                }
            }
        }
        catch (Exception e) {
            org.apache.log4j.Logger.getLogger("H").fatal(e);
        }
        return false;
    }

    private LinkedList<ExcelField> checkPushEntity(final PushEntity pushEntity, final ExcelField excelField, final Class c, final LinkedList<ExcelField> brokenRows) {
        if (c == CertificateInfo.class) {
            if (pushEntity.isLoadedSuccessfully()) {
                getLogger().log("00 - строка " + excelField.getRowNumber()
                        + ": проверка удостоверения успешно завершена");
            } else {
                getLogger().log("12  - строка " + excelField.getRowNumber()
                        + ": ошибка данных.  Удостоверение в БД не идентифицировано");
                brokenRows.add(excelField);

            }
        } else if (c == PersonInfo.class) {
            if (pushEntity.isLoadedSuccessfully()) {
                getLogger().log("00 - строка " + excelField.getRowNumber()
                        + ": проверка лица успешно завершена");
            } else {
                getLogger().log("12  - строка " + excelField.getRowNumber()
                        + ": ошибка данных.  Лицо в БД не идентифицировано");
                brokenRows.add(excelField);

            }
        }
        return brokenRows;
    }

    private void chooseFile(final JFileChooser chooser) throws HeadlessException {
        chooser.setFileFilter(new FileNameExtensionFilter("Excel 97-2003 file", "xls"));
        int showOpenDialog = chooser.showOpenDialog(this);
        if (showOpenDialog == JFileChooser.APPROVE_OPTION) {
            getLogger().setLogFile(chooser.getSelectedFile());
            fileNameVerificaionResult = FileNameParser.checkSelectedFileName(chooser.getSelectedFile().getName());
            if (fileNameVerificaionResult.getResult().getMessageLevel() != MessageLevel.FILE_FATAL) {
                new FileSwingWorker(chooser).execute();
            } else {
                Boolean log = getLogger().log(fileNameVerificaionResult.getResult().getMessage());
                int showConfirmDialog = JOptionPane.showConfirmDialog(this, "Ошибка в имени файла( " + chooser.getSelectedFile().getName().replaceAll(".xls", "") + " ): " + fileNameVerificaionResult.getResult().getMessage() + ". \nВыбрать другой?", "Ошибка", JOptionPane.YES_NO_OPTION);
                if (showConfirmDialog == JOptionPane.YES_OPTION) {
                    chooseFile(chooser);
                }
            }

        }
    }

    private String loadFile(File f) {
        brokenExcelRows = new ArrayList<Cell[]>();
        ExcelEntitiesConstructor entitiesConstructor = new ExcelEntitiesConstructor();
        HashMap<Integer, Class> a = fillMap();
        brokenRows = new LinkedList<ExcelField>();
        pushEntity = new PushEntity();

        ExcelFile construct = null;
        try {
            construct = entitiesConstructor.construct(a, f, getLogger(), fileNameVerificaionResult);
        }
        catch (IOException ex) {
            Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
        }
        catch (BiffException ex) {
            Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
        }

        boolean orgchecked = false;
        orgId = DatabaseWorker.organiztionCheck(construct.getCommonInfo());

        orgchecked = !( orgId == null );
        if (orgchecked) {
            pushEntity=new PushEntity();
            pushEntity.setOrganiztionId(orgId);
            OrganizationInfo oi = construct.getCommonInfo().getOrganizationInfo();
            oi.setOrgId(orgId);
            DatabaseWorker.pushOrganization(oi);
            getLogger().log("00  - УПО: проверка успешно завершена");

            LinkedList<ExcelField> rows = construct.getRows();
            ExcelFile fileWithIncorrectInfo = null;
            rowcounter = 0;
            for (final ExcelField excelField : rows) {
                rowcounter++;
                checkExcelField(excelField, oi);
            }fileWithIncorrectInfo = new ExcelFile(construct.getCommonInfo(), construct.getInfoSheetHeader(), brokenRows);

                if (!brokenExcelRows.isEmpty()) {
                    fileWithIncorrectInfo.add(brokenExcelRows);
                }
                String name = FileToFixCreator.create(fileWithIncorrectInfo, fileNameVerificaionResult.getFileNameInfo());
                return name;
        } else {
            getLogger().log("11  - УПО: критическая ошибка данных. УПО не идентифицировано. Обработка файла прервана");
        }
        return null;
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    //@SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jScrollPane1 = new JScrollPane();
        jTextArea1 = new JTextArea();
        jLabel1 = new JLabel();
        jToolBar1 = new JToolBar();
        jButton1 = new JButton();
        jButton2 = new JButton();
        jMenuBar1 = new JMenuBar();
        jMenu1 = new JMenu();
        jMenuItem1 = new JMenuItem();
        jSeparator1 = new Separator();
        jSeparator2 = new Separator();
        jMenuItem2 = new JMenuItem();
        jMenu2 = new JMenu();
        jCheckBoxMenuItem1 = new JCheckBoxMenuItem();
        jMenu3 = new JMenu();
        jMenuItem3 = new JMenuItem();

        setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
        setTitle("Импорт информации");






        addWindowListener(new WindowAdapter()   {

            public void windowClosing(WindowEvent evt) {
                formWindowClosing(evt);
            }
        });
        jScrollPane1.setName("jScrollPane1");
        jTextArea1.setColumns(20);
        jTextArea1.setEditable(false);
        jTextArea1.setFont(new Font("Times New Roman", 0, 14));
        jTextArea1.setRows(5);
        jTextArea1.setName("jTextArea1");
        jScrollPane1.setViewportView(jTextArea1);
        jLabel1.setText("Ход выполнения:");
        jLabel1.setName("jLabel1");
        jToolBar1.setFloatable(false);
        jToolBar1.setRollover(true);
        jToolBar1.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
        jToolBar1.setDoubleBuffered(true);
        jToolBar1.setName("jToolBar1");
        jButton1.setIcon(new ImageIcon(getClass().getResource("/res/folder_open_1.png")));
        jButton1.setText("Открыть файл");
        jButton1.setToolTipText("Открыть файл");
        jButton1.setFocusable(false);
        jButton1.setHorizontalTextPosition(SwingConstants.CENTER);
        jButton1.setName("jButton1");
        jButton1.setVerticalTextPosition(SwingConstants.BOTTOM);
        jButton1.addActionListener(new ActionListener()   {

            public void actionPerformed(ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });
        jToolBar1.add(jButton1);
        jButton2.setIcon(new ImageIcon(getClass().getResource("/res/edit-clear.png")));
        jButton2.setText("Очистить лог");
        jButton2.setFocusable(false);
        jButton2.setHorizontalTextPosition(SwingConstants.CENTER);
        jButton2.setName("jButton2");
        jButton2.setVerticalTextPosition(SwingConstants.BOTTOM);
        jButton2.addActionListener(new ActionListener()   {

            public void actionPerformed(ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });
        jToolBar1.add(jButton2);
        jMenuBar1.setName("jMenuBar1");
        jMenu1.setText("Файл");
        jMenu1.setName("jMenu1");
        jMenuItem1.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, InputEvent.CTRL_MASK));
        jMenuItem1.setIcon(new ImageIcon(getClass().getResource("/res/folder_open_1.png")));
        jMenuItem1.setText("Выбрать файл для обработки");
        jMenuItem1.setName("jMenuItem1");
        jMenuItem1.addActionListener(new ActionListener()   {

            public void actionPerformed(ActionEvent evt) {
                jMenuItem1ActionPerformed(evt);
            }
        });
        jMenu1.add(jMenuItem1);
        jSeparator1.setName("jSeparator1");
        jMenu1.add(jSeparator1);
        jSeparator2.setName("jSeparator2");
        jMenu1.add(jSeparator2);
        jMenuItem2.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Q, InputEvent.CTRL_MASK));
        jMenuItem2.setIcon(new ImageIcon(getClass().getResource("/res/exit.png")));
        jMenuItem2.setText("Выход");
        jMenuItem2.setName("jMenuItem2");
        jMenuItem2.addActionListener(new ActionListener()   {

            public void actionPerformed(ActionEvent evt) {
                jMenuItem2ActionPerformed(evt);
            }
        });
        jMenu1.add(jMenuItem2);
        jMenuBar1.add(jMenu1);
        jMenu2.setText("Опции");
        jMenu2.setName("jMenu2");
        jMenu2.addActionListener(new ActionListener()   {

            public void actionPerformed(ActionEvent evt) {
                jMenu2ActionPerformed(evt);
            }
        });
        jCheckBoxMenuItem1.setText("Сортировать по папкам с именем ОГРН");
        jCheckBoxMenuItem1.setName("jCheckBoxMenuItem1");
        jCheckBoxMenuItem1.addActionListener(new ActionListener()   {

            public void actionPerformed(ActionEvent evt) {
                jCheckBoxMenuItem1ActionPerformed(evt);
            }
        });
        jMenu2.add(jCheckBoxMenuItem1);
        jMenuBar1.add(jMenu2);
        jMenu3.setText("Действия");
        jMenu3.setName("jMenu3");
        jMenuItem3.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, InputEvent.CTRL_MASK));
        jMenuItem3.setIcon(new ImageIcon(getClass().getResource("/res/edit-clear.png")));
        jMenuItem3.setText("Очистить лог");
        jMenuItem3.setName("jMenuItem3");
        jMenuItem3.addActionListener(new ActionListener()   {

            public void actionPerformed(ActionEvent evt) {
                jMenuItem3ActionPerformed(evt);
            }
        });
        jMenu3.add(jMenuItem3);
        jMenuBar1.add(jMenu3);

        setJMenuBar(jMenuBar1);

        GroupLayout layout = new GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
                layout.createParallelGroup(Alignment.LEADING).addComponent(jToolBar1, GroupLayout.DEFAULT_SIZE, 558, Short.MAX_VALUE).addGroup(layout.createSequentialGroup().addContainerGap().addComponent(jScrollPane1, GroupLayout.DEFAULT_SIZE, 534, Short.MAX_VALUE).addContainerGap()).addGroup(layout.createSequentialGroup().addGap(210, 210, 210).addComponent(jLabel1, GroupLayout.DEFAULT_SIZE, 129, Short.MAX_VALUE).addGap(219, 219, 219)));
        layout.setVerticalGroup(
                layout.createParallelGroup(Alignment.LEADING).addGroup(layout.createSequentialGroup().addComponent(jToolBar1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE).addPreferredGap(ComponentPlacement.RELATED).addComponent(jLabel1).addPreferredGap(ComponentPlacement.RELATED).addComponent(jScrollPane1, GroupLayout.DEFAULT_SIZE, 310, Short.MAX_VALUE).addGap(17, 17, 17)));

        pack();
    }// </editor-fold>//GEN-END:initComponents
    public static ArrayList<Cell[]> brokenExcelRows;

    private void jMenuItem1ActionPerformed(ActionEvent evt) {//GEN-FIRST:event_jMenuItem1ActionPerformed
        JFileChooser chooser;
        if (ConfigurationWorker.readConfiguration() == null) {
            chooser = new JFileChooser();
        } else {
            chooser = new JFileChooser(ConfigurationWorker.readConfiguration().getConfigFilePath());
        }
        chooseFile(chooser);
    }//GEN-LAST:event_jMenuItem1ActionPerformed

    private void jMenu2ActionPerformed(ActionEvent evt) {//GEN-FIRST:event_jMenu2ActionPerformed
    }//GEN-LAST:event_jMenu2ActionPerformed

    private void jCheckBoxMenuItem1ActionPerformed(ActionEvent evt) {//GEN-FIRST:event_jCheckBoxMenuItem1ActionPerformed
    }//GEN-LAST:event_jCheckBoxMenuItem1ActionPerformed

    private void formWindowClosing(WindowEvent evt) {//GEN-FIRST:event_formWindowClosing
        TestInitializer.stop();
    }//GEN-LAST:event_formWindowClosing

    private void jMenuItem2ActionPerformed(ActionEvent evt) {//GEN-FIRST:event_jMenuItem2ActionPerformed
        System.exit(0);
    }//GEN-LAST:event_jMenuItem2ActionPerformed

    private void jMenuItem3ActionPerformed(ActionEvent evt) {//GEN-FIRST:event_jMenuItem3ActionPerformed
        jTextArea1.setText("");
    }//GEN-LAST:event_jMenuItem3ActionPerformed

    private void jButton1ActionPerformed(ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        jMenuItem1.doClick();
    }//GEN-LAST:event_jButton1ActionPerformed

    private void jButton2ActionPerformed(ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
        jTextArea1.setText("");
    }//GEN-LAST:event_jButton2ActionPerformed

    public static boolean sort() {
        return jCheckBoxMenuItem1.isSelected();
    }

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {

        SwingUtilities.invokeLater(new Runnable()           {

            @Override
            public void run() {
                new Main().setVisible(true);
            }
        });

    }

    public static Boolean appendToLog(final String message) {
        if (jTextArea1 != null) {
            String text = jTextArea1.getText();
            Runnable r = new Runnable()           {

                @Override
                public void run() {
                    jTextArea1.append(message + "\n");
                    jTextArea1.setCaretPosition(jTextArea1.getText().length());
                }
            };
            SwingUtilities.invokeLater(new Thread(r));
            return !jTextArea1.getText().equals(text);
        } else {
            throw new NullPointerException("jTextArea does not exist");
        }

    }

    private static String text() {
        return jTextArea1.getText();
    }
    private PushEntity pushEntity = new PushEntity();

    public PushEntity getPushEntity() {
        return pushEntity;
    }

    public void setPushEntity(PushEntity pushEntity) {
        this.pushEntity = pushEntity;
    }
    LinkedList<ExcelField> brokenRows = new LinkedList<ExcelField>();

    public LinkedList<ExcelField> getBrokenRows() {
        return brokenRows;
    }

    public void setBrokenRows(LinkedList<ExcelField> brokenRows) {
        this.brokenRows = brokenRows;
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private static JButton jButton1;
    private static JButton jButton2;
    private static JCheckBoxMenuItem jCheckBoxMenuItem1;
    private static JLabel jLabel1;
    private static JMenu jMenu1;
    private static JMenu jMenu2;
    private static JMenu jMenu3;
    private static JMenuBar jMenuBar1;
    private static JMenuItem jMenuItem1;
    private static JMenuItem jMenuItem2;
    private static JMenuItem jMenuItem3;
    private static JScrollPane jScrollPane1;
    private static Separator jSeparator1;
    private static Separator jSeparator2;
    private static JTextArea jTextArea1;
    private static JToolBar jToolBar1;
    // End of variables declaration//GEN-END:variables
    private int rowcounter = 0;
    private static ComplexLogger tal;

    private ComplexLogger getLogger() {
        if (tal == null) {
            tal = new ComplexLogger();
        }
        return tal;
    }

    private class FileSwingWorker extends SwingWorker {

        private final JFileChooser chooser;

        public FileSwingWorker(JFileChooser chooser) {
            this.chooser = chooser;
        }

        @Override
        protected Object doInBackground() throws Exception {
            final File selectedFile = chooser.getSelectedFile();

            getLogger().log("--------------------\nОбработка нового файла: \n" + selectedFile.getName() + "\n--------------------\n");
            ConfigurationWorker.writeConfiguration(new Configuration(selectedFile.getParent()));
            String loadFile = loadFile(selectedFile);
            getLogger().log("--------------------\nОбработка файла ‘" + selectedFile.getName() + "’ завершена."
                    + "\nКоличество записей в файле – " + rowcounter + ","
                    + "\n количество обработанных записей - " + ( rowcounter - brokenRows.size() ) + ".");
            if (loadFile != null && !loadFile.equals("")) {
                getLogger().log("\nНеобработанные записи – в файле ‘" + loadFile + "’");
            }
            getLogger().log("\n--------------------\n");
            Thread.currentThread().interrupt();
            return null;
        }
    }
}
